//
//  EPMLoginManager.m
//  myXianfeng
//
//  Created by 马继鵬 on 17/4/26.
//  Copyright © 2017年 EPM. All rights reserved.
//

#import "EPMLoginManager.h"

@implementation EPMLoginManager


+ (instancetype)sheardManger{
    static EPMLoginManager* _mgr;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken,^{
        _mgr = [EPMLoginManager new];
    });
    return _mgr;
}

#pragma mark - 短信验证登录 -

- (void)loginWithPhone:(NSString*)phoneNum verify:(NSString*)verify finished:(void(^)(SMSSDKUserInfo *userInfo, NSError *error))reasult {

    [SMSSDK commitVerificationCode:verify phoneNumber:phoneNum zone:@"86" result:^(SMSSDKUserInfo *userInfo, NSError *error) {
        if (error == nil){
            self.isLogin = YES;
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:KisLogin];
            [[NSUserDefaults standardUserDefaults] setObject:phoneNum forKey:KPhoneNum];
            self.phoneNum = phoneNum;
            [[NSNotificationCenter defaultCenter]postNotificationName:EPMLoginChangedNotification object:nil userInfo:@{KIsLogin : @(self.isLogin)}];
            
        }
        reasult(userInfo,error);
    }];
   
}

- (void)getVerifyWithPhoneNum:(NSString*)phoneNum reasult:(void(^)(NSError* error)) reasult{
    [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:phoneNum zone:@"86" customIdentifier:nil result:reasult];
}

- (BOOL)isLogin{
    return [[[NSUserDefaults standardUserDefaults] valueForKey:KisLogin] boolValue];
}

#pragma mark - 第三方登录 -


@end
